<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>表单校验-20302120121-邹圣洁</title>
    <link rel="stylesheet" href="download/font_ewrrrydj26/iconfont.css">
    <style>
        body,ul,p{
            padding: 0;
            margin: 0;
        }
        body{
            background-image: url(img/csbj.jpg);
        }
        ul{
            list-style: none;
        }
        a{
            text-decoration: none;
            color: rgb(255, 255, 255);
            display: inline-block;
            margin-top: 30px;
            margin-left: 30px;
        }
        header{
            background-color: #21222467;
            padding-bottom: 60px;
        }
        header h2{
            margin-left: 50px;
            margin-top: 30px;
            color: #fff;
            font-weight: normal;
        }
        
        #fm div{
            display: flex;
            width: 100%;
            align-items: center;
            margin-top: 40px;
        }
        .input{
            width: 85%;
            margin-left: 50px;
            height: 25px;
            border: none;
            outline: none;
            padding-bottom: 10px;
            padding-top: 10px;
            font-size: 14px;
            border-bottom: 1px solid #fff;
            background-color: rgba(255, 255, 255, 0);
        }
        .error{
            font-size: 12px;
            font-weight: bold;
            margin-left: 10px;
            color: rgb(255, 255, 255);
            display: none;
            margin-top: 5px;
        }
        .queren{
            width: 85%;
            height: 45px;
            border-radius:5px ;
            margin: 0 auto;
            background-color: #0086f7;
            color: rgb(255, 255, 255);
            border: none;
            font-size: 16px;
            font-weight: bold;
            margin-left: 50px;
        }
        .yuedu{
            font-size: 12px;
            color: rgb(255, 255, 255);
            display: flex;
            width: 100%;
            margin-top: 20px;
        }
        .yuedu>span{
            margin-right: 18%;
        }
        .yuedu>#dui{
            margin-left: 5%;
            margin-right: 10px;
        }
        .fa{
            display: flex;
            margin-top: 100px;
            margin-bottom: 50px;
            margin-left: 40px;
        }
        .fa>li{
            height: 50px;
            margin-left: 20px;
        }
        .icon-weixin,.icon-qq,.icon-zhifubao,.icon-xinlangweibo,.icon-baidu{
            font-size: 25px;
            color: #fff;
        }
        .quan{
            height: 50px;
            width: 50px;
            border-radius: 50px;
            border: 1px solid #fff;
            text-align: center;
            line-height: 50px;
        }
    </style>

</head>
<body>
    <header>
        <a href="wode.html" target="_blank"><span class="iconfont icon-fanhui"></span></a>
        <h2>账号密码登录</h2>
    



    <div class="zhong">
        <form action="index.html"  method="post" id="fm" name="fm" onsubmit="return checkform()">
            <div>
                <input type="text" id="user" name="user" class="input" placeholder="  请输入您的手机号">
                <span class="error">手机号输入不正确</span>
            </div>

            <div>
                <input type="password" id="pwd" name="pwd" class="input" placeholder="  请输入输入密码">
                <span class="error">密码应为6-12位</span>
            </div>

            <div>
                <input type="password" id="pwd2" name="pwd2" class="input" placeholder="  请确认密码">
                <span class="error">两次密码不相同</span>
            </div>

            <div>
                <input type="submit" value="注册" class="queren">
            </div>

        </form>
    </div>

    


    <ul class="fa">
        <li>
            <div class="quan"><span class="iconfont icon-weixin"></span></div>
        </li>
        <li>
            <div class="quan"><span class="iconfont icon-qq"></span></div>
        </li>
        <li>
            <div class="quan"><span class="iconfont icon-zhifubao"></span></div>
        </li>
        <li>
            <div class="quan"><span class="iconfont icon-xinlangweibo"></span></div>
        </li>
        <li>
            <div class="quan"><span class="iconfont icon-baidu"></span></div>
        </li>
    </ul>
    <div class="yuedu">
        <input type="checkbox" id="dui" name="yuedu"/> 
        <span>已阅读并同意携程的《用户协议》和《个人信息保护指引》</span>
       </div>
</header>

    <script>
        var user = document.getElementById("user");
        var error = document.getElementsByClassName("error");
        var pwd = document.getElementById("pwd");
        var pwd2 = document.getElementById("pwd2");
        
        user.onchange = checkuser; 
        pwd.onchange = checkpwd;
        pwd2.onchange = checkpwd2;
        
        function checkuser(){
            if(user.value.length ==11){
                error[0].style.display = "none";
                return 1;
            }
            else{
                error[0].style.display = "block";
                return 0;
            }
        }

        function checkpwd(){
            if(pwd.value.length > 5 && pwd.value.length < 12){
                error[1].style.display = "none";
                return 1;
            }
            else{
                error[1].style.display = "block";
                return 0;
            }
        }

        function checkpwd2(){
            if(pwd.value == pwd2.value){
                error[2].style.display = "none";
                return 1;
            }
            else{
                error[2].style.display = "block";
                return 0;
            }
        }

        function checkform(){
            var rs = checkuser()*checkpwd()*checkpwd2();
            if(rs == 0){
                return false;
            }
            else{
                return true;
            }
        }

    </script>
</body>
</html>